package model

import (
	"github.com/gomodule/redigo/redis"
	"tizhi_front/nspel"
)

type BodyShape struct {
	Id       int64  `gorm:"primary_key;column:id"`
	Level    string `gorm:"column:level"`
	Name     string `gorm:"column:name"`
	Comment  string `gorm:"column:comment"`
	Analysis string `gorm:"column:analysis"`
}

func (*BodyShape) TableName() string {
	return "body_shape"
}

type BodyShape0 struct {
	Comment  string `gorm:"column:comment"`
	Analysis string `gorm:"column:analysis"`
}

func (*BodyShape0) TableName() string {
	return "body_shape"
}

type BodyShape1 struct{}

func (*BodyShape1) SelectAll() (bodyShapes []BodyShape0, err error) {
	key := "body_shape0.all"
	err = nspel.RedisGetGob(key, &bodyShapes)
	if err == nil {
		return
	}
	if err != redis.ErrNil {
		nspel.Error(err)
	} else {
		err = nil
	}
	if err = nspel.GetOrm().Select([]string{"comment", "analysis"}).Find(&bodyShapes).Error; err != nil {
		return
	}
	nspel.RedisSetGob(key, bodyShapes)
	return
}
